import { axiosInstance } from 'src/boot/axios'
import CommonConfig from 'src/assets/js/config'

const baseUrl = CommonConfig.upmsUrl + '/v1'

/**
 * 获取用户菜单
 * roleId 角色Id列表
 * terminalType 设备类型
 * **/
export function getMenuList (params) {
  const newUrl = `${baseUrl}/menu_list_by_role`

  return axiosInstance.get(newUrl, { params }).then((res) => {
    return Promise.resolve(res)
  })
}

/**
 * 列举用户权限映射数组
 * roleId 角色Id列表
 * clientType 设备类型
 * **/
export function getPermissions (userId) {
  const newUrl = `${baseUrl}/users/${userId}/view_privileges`

  let reqData = {
    params: {
      clientType: 'pc'
    }
  }

  return axiosInstance.get(newUrl, reqData).then((res) => {
    return Promise.resolve(res)
  })
}
